$(function () {
    var form = layui.form
    form.verify({
        diff: function (value) {
            var oldPwd = $(".layui-form input[name=oldPwd]").val()
            if (oldPwd === value) {
                return '新密码和原密码不能一样'
            }
        },

        same: function (value) {
            var newPwd = $(".layui-form input[name=newPwd]").val()
            if (newPwd !== value) {
                return '俩次输入的密码不一样'
            }
        }
    })


    $('.layui-form').submit(function (e) {
        e.preventDefault()
        var fd = $(this).serialize()
        $.ajax({
            type: 'post',
            url: 'my/updatepwd',
            data: fd,
            success: function (res) {
                if (res.status === 0) {
                    layer.msg(res.message)
                }
            }
        })
    })
})